using System;
using System.Collections.Generic;
using System.Text;

using System.Net;
using System.Net.Sockets;

namespace Parsifal
{
    /// <summary>
    /// classe che gestisce gli eventi inviati dal parser protocol client
    /// </summary>
    public class ManageParserClientEvent
    {

        private protocolParserClient iProtocolParserClient;
        private ManageSendDataClient iManageSendDataClient;


        //LOG
        private Utility iUtility;

        public ManageParserClientEvent(protocolParserClient aProtocolParserClient,ManageSendDataClient aManageSendDataClient,Utility aUtility)
        {
            iProtocolParserClient = aProtocolParserClient;
            iManageSendDataClient = aManageSendDataClient;


            addEventHandlerForParser();

            iUtility = aUtility;
        }

        private void addEventHandlerForParser()
        {
            iProtocolParserClient._OnConnectTo += new protocolParserClient.OnConnectTo(iProtocolParserClient__OnConnectTo);
            iProtocolParserClient._OnCreateServer +=new protocolParserClient.OnCreateServer(iProtocolParserClient__OnCreateServer);
            iProtocolParserClient._OnMessageReceived +=new protocolParserClient.OnMessaggeReceived(iProtocolParserClient__OnMessageReceived);
            iProtocolParserClient._OnPlaylistItem +=new protocolParserClient.OnPlaylistItem(iProtocolParserClient__OnPlaylistItem);
            iProtocolParserClient._OnPlaylistItemAdd +=new protocolParserClient.OnPlaylistItemAdd(iProtocolParserClient__OnPlaylistItemAdd);
            iProtocolParserClient._OnPlaylistItemLast +=new protocolParserClient.OnPlaylistItemLast(iProtocolParserClient__OnPlaylistItemLast);
            iProtocolParserClient._OnPlaylistItemRemove +=new protocolParserClient.OnPlaylistItemRemove(iProtocolParserClient__OnPlaylistItemRemove);
            iProtocolParserClient._OnSongActive +=new protocolParserClient.OnSongActive(iProtocolParserClient__OnSongActive);
            iProtocolParserClient._OnSpeackerOff +=new protocolParserClient.OnSpeackerOff(iProtocolParserClient__OnSpeackerOff);
            iProtocolParserClient._OnSpeackerOn +=new protocolParserClient.OnSpeackerOn(iProtocolParserClient__OnSpeackerOn);
            iProtocolParserClient._OnStopServer +=new protocolParserClient.OnStopServer(iProtocolParserClient__OnStopServer);
            iProtocolParserClient._OnWelcomeNick +=new protocolParserClient.OnWelcomeNick(iProtocolParserClient__OnWelcomeNick);
        }


        private void iProtocolParserClient__OnWelcomeNick(Socket remote,string data, eProtocolClientEvent iRes)
        {
            iUtility.LogEvent("MANAGE PARSER CLIENT: Lanciato l'evento OnWelcomeNick!", NLog.LogLevel.Info);
        }

        private void iProtocolParserClient__OnStopServer(Socket remote, eProtocolClientEvent iRes)
        {
            iUtility.LogEvent("MANAGE PARSER CLIENT: Lanciato l'evento OnSTopServer!", NLog.LogLevel.Info);
        }

        private void iProtocolParserClient__OnSpeackerOn(Socket remote, eProtocolClientEvent iRes)
        {
            iUtility.LogEvent("MANAGE PARSER CLIENT: Lanciato l'evento OnSpeackerOn!", NLog.LogLevel.Info);
        }

        private void iProtocolParserClient__OnSpeackerOff(Socket remote, eProtocolClientEvent iRes)
        {
            iUtility.LogEvent("MANAGE PARSER CLIENT: Lanciato l'evento OnSpeackerOff!", NLog.LogLevel.Info);
        }

        private void iProtocolParserClient__OnSongActive(PlaylistItem aItem, Socket remote, eProtocolClientEvent iRes)
        {
        }

        private void iProtocolParserClient__OnPlaylistItemRemove(PlaylistItem aItem, Socket remote, eProtocolClientEvent iRes)
        {
            iUtility.LogEvent("MANAGE PARSER CLIENT: Lanciato l'evento OnPlaylistItemRemove!", NLog.LogLevel.Info);
        }

        private void iProtocolParserClient__OnPlaylistItemLast(Socket remote, eProtocolClientEvent iRes)
        {
            iUtility.LogEvent("MANAGE PARSER CLIENT: Lanciato l'evento OnPlaylistItemLast!", NLog.LogLevel.Info);
        }

        private void iProtocolParserClient__OnPlaylistItemAdd(PlaylistItem aItem, Socket remote, eProtocolClientEvent iRes)
        {
            iUtility.LogEvent("MANAGE PARSER CLIENT: Lanciato l'evento OnPlaylistItemAdd!", NLog.LogLevel.Info);
        }

        private void iProtocolParserClient__OnPlaylistItem(PlaylistItem aItem, Socket remote, eProtocolClientEvent iRes)
        {
            iUtility.LogEvent("MANAGE PARSER CLIENT: Lanciato l'evento OnPLaylistItem!", NLog.LogLevel.Info);
        }

        private void iProtocolParserClient__OnMessageReceived(string from, string to, Socket remote, eProtocolClientEvent iRes)
        {
            iUtility.LogEvent("MANAGE PARSER CLIENT: Lanciato l'evento OnMessageReceived!", NLog.LogLevel.Info);
        }

        private void iProtocolParserClient__OnCreateServer(Socket remote, eProtocolClientEvent iRes)
        {
            iUtility.LogEvent("MANAGE PARSER CLIENT: Lanciato l'evento OnCreateServer!", NLog.LogLevel.Info);
        }


        private void iProtocolParserClient__OnConnectTo(Socket remote, string data, eProtocolClientEvent iRes)
        {
            iUtility.LogEvent("MANAGE PARSER CLIENT: Lanciato l'evento OnConnectTo!", NLog.LogLevel.Info);
        }




        public void SendDataToParserClient(string data, Socket remote)
        {
            iProtocolParserClient.GetDataFromSocket(data, remote);
        }

    }
}
